﻿using System;
using SimpleServiceBus.Endpoint;
using SimpleServiceBus.Endpoint.Management.Monitoring;
using SimpleServiceBus.Messages.Management.Monitoring;

namespace SimpleServiceBus.Tests.Stubs
{
    public class TestStatusProbe : IEndpointStatusProbe
    {
        public TestStatusProbe()
        {
            Value =
                (new Random(DateTime.Now.Second).NextDouble()*new Random(DateTime.Now.Millisecond).NextDouble()*10).
                    ToString();
        }

        public TestStatusProbe(string value)
        {
            Value = value;
        }

        public string Value { get; set; }
        public DateTime TestCustomProperty { get; set; }
        public string TestCustomProperty2 { get; set; }

        #region IEndpointStatusProbe Members

        public string Name { get; set; }

        public string UnitOfMeasurement { get; set; }

        public bool CanAggregate { get; set; }

        public MeasurementDataType DataType { get; set; }

        public object Clone()
        {
            return MemberwiseClone();
        }

        public EndpointMeasurement TakeMeasurement(IMessagingEndpoint endpoint)
        {
            return new EndpointMeasurement
                       {
                           Name = Name,
                           DataType = MeasurementDataType.Numeric,
                           Value = Value,
                           UnitOfMeasurement = "Thingies/Mile",
                           CanAggregate = true
                       };
        }

        #endregion
    }
}